package com.sz.sendmsg.controller;


import com.sz.sendmsg.feign.LogFeign;
import com.sz.sendmsg.feign.QueryServiceFeign;
import com.sz.sendmsg.feign.TransferAccFeign;
import com.sz.sendmsg.vo.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;


@RestController
public class ShiroController {
    @Autowired
    QueryServiceFeign queryServiceFeign;
    @Autowired
    TransferAccFeign transferAccFeign;
    @Autowired
    LogFeign logFeign;
    @PostMapping("/query/find")
    public ResultVO queryFind(@RequestBody TransferVO vo){

        ResultVO resultVO = new ResultVO();
        resultVO.setMsg("success");
        QueryVO queryVO = queryServiceFeign.queryByCondtion(vo);
        resultVO.setT(queryVO);
        return resultVO;
    }
    @GetMapping("/query/find/all")
    public ResultVO queryFind1(Integer page,Integer limit){

        TransferVO vo = new TransferVO();
        vo.setIndex(page);
        vo.setPageSize(limit);
        ResultVO resultVO = new ResultVO();
        resultVO.setMsg("success");
        QueryVO queryVO = queryServiceFeign.queryByCondtion(vo);
        queryVO.setPageCount(queryVO.getPageCount()*limit);
        resultVO.setT(queryVO);
        return resultVO;
    }

    @PostMapping("/transfer/find")
    public ResultVO transferFind(@RequestBody PageVO vo){
        ResultVO resultVO = new ResultVO();
        resultVO.setMsg("success");
        QueryVO queryVO = queryServiceFeign.getQueryErr(vo);
        resultVO.setT(queryVO);


        return resultVO;
    }
    @PostMapping("/transfer/modify")
    public ResultVO transferModify(@RequestBody TransferInfoVO vo){
        ResultVO resultVO = new ResultVO();
        String str = transferAccFeign.retryAcc(vo);
        resultVO.setMsg("success");
        resultVO.setT(str);
        return resultVO;
    }
    @PostMapping("/exce/find")
    public ResultVO execFind(@RequestBody  PageVO vo){
        ResultVO resultVO = new ResultVO();
        ExceQueryVo execFindAll = logFeign.getExecFindAll(vo);
        resultVO.setMsg("success");
        resultVO.setT(execFindAll);
        return resultVO;
    }
    @PostMapping("/exce/modify/{name}")
    public ResultVO exceModify(@PathVariable("name") String name){

        ResultVO resultVO = new ResultVO();
        resultVO.setMsg("success");
        String s = logFeign.modifyStatus(name);
        resultVO.setT(s);
        return resultVO;
    }
    @PostMapping("/log/find")
    public ResultVO logFind(@RequestBody PageVO vo){
        System.out.println(vo);
        ResultVO resultVO = new ResultVO();
        resultVO.setMsg("success");
        LogQueryVO logs = logFeign.getLogs(vo);
        resultVO.setT(logs);

        return resultVO;
    }
    @PostMapping("/exce/cancel/{name}")
    public ResultVO exceCancel(@PathVariable String name){
        System.out.println(name);
        ResultVO resultVO = new ResultVO();
        resultVO.setMsg("success");
        logFeign.cancelStatus(name);

        return resultVO;
    }

}
